/**
 * @author admin
 */
public class Bullet implements Runnable {

    int x;
    int y;
    int direct = 0;
    int speed = 10;
    Boolean isLive = true;

    public Bullet(int x, int y, int direct) {
        this.x = x;
        this.y = y;
        this.direct = direct;
    }

    @Override
    public String toString() {
        return "Bullet{" +
                "x=" + x +
                ", y=" + y +
                ", direct=" + direct +
                ", speed=" + speed +
                ", isLive=" + isLive +
                '}';
    }

    @Override
    public void run() {
        while(true){

            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            switch (direct){
                case 0:
                    y-=speed;
                    break;
                case 1:
                    x+=speed;
                    break;
                case 2:
                    y+=speed;
                    break;
                case 3:
                    x-=speed;
                    break;
            }
            if (!(x>=0 && x<1000 && y>=0 && y < 750 && isLive)){
                isLive = false;
                break;
            }


        }
    }
}
